<template>
  <div class="platform-container">
    <div class="header">
      <img src="../../assets/platform/header.png" alt="" />
      <div class="btn-div">
        <div @click="handleUserClick" style="cursor:pointer;">
          <img src="../../assets/platform/user-icon.png" alt="" />
          <span>Admin</span>
        </div>
        <div @click="doLogout">
          <img src="../../assets/platform/logout-icon.png" alt="" />
          <span>退出登录</span>
        </div>
      </div>
      <!-- <div class="upleft">
        <img src="../../assets/platform/upleft.png" alt="" />
      </div> -->
    </div>

    <!-- 设备数量地区分布 -->
    <quantityAndRegion> </quantityAndRegion>
    <!-- 设备类型及状态分布 -->
    <typeAndStatus></typeAndStatus>
    <!-- 设备流量/在线数 -->
    <equipmentFlow></equipmentFlow>
    <!-- 设备CPU占比 -->
    <deviceCPU></deviceCPU>
    <!-- 设备内存占比 -->
    <memoryRatio></memoryRatio>
    <!-- 地图 -->
    <provincialMap></provincialMap>
  </div>
</template>

<script>
import { mapGetters, mapActions } from 'vuex'
import quantityAndRegion from '../../components/platform/quantityAndRegion'
import typeAndStatus from '../../components/platform/TypeAndStatus.vue'
import equipmentFlow from '../../components/platform/EquipmentFlow.vue'
import deviceCPU from '../../components/platform/DeviceCPU.vue'
import memoryRatio from '../../components/platform/MemoryRatio.vue'
import provincialMap from '../../components/platform/ProvincialMap.vue'
export default {
  name: 'index',
  components: {
    quantityAndRegion,
    typeAndStatus,
    equipmentFlow,
    deviceCPU,
    memoryRatio,
    provincialMap
  },
  data() {
    return {}
  },
  methods: {
    ...mapActions(['toggleSideBar', 'logout']),
    doLogout() {
      this.logout().then(() => {
        this.$router.push('/login')
        sessionStorage.clear()
        window.location.reload()
      })
    },
    handleUserClick() {
      this.$router.push('/workbench/device/deviceList')
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss">
.platform-container {
  width: 1920px;
  height: 1080px;
  background: url(../../assets/platform/bg.png) no-repeat center center;
  background-size: cover;
  position: relative;
  font-family: PingFang SC-Medium, PingFang SC;
}
.header {
  width: 100%;
  height: 88px;
  text-align: center;
  position: relative;
  .btn-div {
    position: absolute;
    right: 27px;
    color: #fff;
    font-size: 14px;
    top: 28px;
    > div {
      display: inline-flex;
      align-items: center;
      margin-left: 40px;
      img {
        width: 20px;
        height: 20px;
        margin-right: 12px;
      }
    }
  }
}
.upleft {
}
</style>
